

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/favicon.png">
  <link rel="icon" type="image/png" href="/blog/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#fff">
  <meta name="description" content="その時を待つよ">
  <meta name="author" content="Isshiki_Hugh">
  <meta name="keywords" content="">
  <title>algorithm-搜索专题 - Isshiki&#39;sBlog</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/blog/lib/hint/hint.min.css" />

  
    
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/atom-one-dark.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_6peoq002giu.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/blog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.0.2"></head>


<body>
  <header style="height: 75vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/blog/">&nbsp;<strong>Isshiki修のBlog</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/blog/img/default.JPG') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2019-11-08 07:32" pubdate>
      2019年11月8日 早上
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.3k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      19
       分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">algorithm-搜索专题</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：2 年前
                
              </p>
            
            <div class="markdown-body" id="post-body">
              <h2 id="0-x-前言"><a href="#0-x-前言" class="headerlink" title="[0.x]前言"></a>[0.x]前言</h2><p>参考书目：<strong>《算法竞赛进阶指导》</strong></p>
<p>语言：$Cpp$</p>
<p><strong>注意</strong>：本大章中统一规定：<br><div class="hljs"><pre><code class="hljs cpp"><span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;邻接表表头：&quot;</span> &lt;&lt; head[x] &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;邻接表下一节点：&quot;</span> &lt;&lt; next[x] &lt;&lt; <span class="hljs-built_in">endl</span>; 
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;邻接表边的终点：&quot;</span> &lt;&lt; ver[x] &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;邻接表边的权值：&quot;</span> &lt;&lt; edge[x] &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;dfs序：&quot;</span> &lt;&lt; dfsn[x] &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;深度：&quot;</span> &lt;&lt; d[x] &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;以x为根节点的树的子节点的大小：&quot;</span> &lt;&lt; size[x] &lt;&lt; <span class="hljs-built_in">endl</span>;</code></pre></div></p>
<a id="more"></a>
<h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li>[1.x]树与图的遍历</li>
<li>[2.x]深搜</li>
<li>[3.x]剪枝</li>
<li>[4.x]广搜</li>
<li>[5.x]广搜变形</li>
</ul>
<hr>
<h2 id="1-x-树与图的遍历"><a href="#1-x-树与图的遍历" class="headerlink" title="[1.x]树与图的遍历"></a>[1.x]树与图的遍历</h2><h3 id="1-1-图的遍历"><a href="#1-1-图的遍历" class="headerlink" title="[1.1]图的遍历"></a>[1.1]图的遍历</h3><div class="hljs"><pre><code class="hljs cpp"><span class="hljs-comment">//dfs遍历存在邻接表里的图</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">dfs</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>&#123;
    flag[x] = <span class="hljs-literal">true</span>;
    dfs[++cnt] = x;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[i])&#123;
        <span class="hljs-keyword">int</span> y = ver[i];
        <span class="hljs-keyword">if</span>(flag[y]) <span class="hljs-keyword">continue</span>;
        dfs(y);
    &#125;
&#125;</code></pre></div>
<h3 id="1-2-图的连通块划分"><a href="#1-2-图的连通块划分" class="headerlink" title="[1.2]图的连通块划分"></a>[1.2]图的连通块划分</h3><p><strong>连通块</strong>的定义：存在无向图的一个组图，任意两个节点之间都存在一条路径使可以<strong>相互达到</strong>，并且这个子图是极大即无法扩张的，则称该子图为无向图的一个连通块。一张不连通的无向图有$2$个或两个以上的连通块，一张<strong>无向连通图</strong>本身就是一个连通块。</p>
<div class="hljs"><pre><code class="hljs cpp"><span class="hljs-comment">//划分连通块,v[x]为x节点所属连通块编号</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">dfs</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>&#123;
    flag[x] = <span class="hljs-literal">true</span>;
    v[x] = cnt;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[x])&#123;
        <span class="hljs-keyword">int</span> y = ver[i];
        <span class="hljs-keyword">if</span>(flag[y]) <span class="hljs-keyword">continue</span>;
        dfs(y);
    &#125;
&#125;

...
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>;i &lt;= n;i++)&#123;
    <span class="hljs-keyword">if</span>(!flag[i])&#123;
    cnt++;
    dfs(i);
    &#125;
&#125;
...</code></pre></div>
<h3 id="1-3-树的遍历"><a href="#1-3-树的遍历" class="headerlink" title="[1.3]树的遍历"></a>[1.3]树的遍历</h3><div class="hljs"><pre><code class="hljs cpp"><span class="hljs-comment">//dfs遍历存在邻接表里的树</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">dfs</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>&#123;
    flag[x] = <span class="hljs-literal">true</span>;
    dfs[++cnt] = x;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[i])&#123;
        <span class="hljs-keyword">int</span> y = ver[i];
        <span class="hljs-keyword">if</span>(flag[y]) <span class="hljs-keyword">continue</span>;
        dfs(y);
    &#125;
    dfs[++cnt] = x;<span class="hljs-comment">//我们需要在遍历树的时候把回溯时的dfs序标记</span>
&#125;
<span class="hljs-comment">/*</span>
<span class="hljs-comment">对树进行如此的dfs处理后会得到这样的一条性质：</span>
<span class="hljs-comment">每个节点会在dfs序数组中出现两次，且以这两个节点为边界的区间恰好是以该节点为根节点的dfs序</span>
<span class="hljs-comment">*/</span>

<span class="hljs-comment">/*</span>
<span class="hljs-comment">二叉树的先序遍历、中序遍历、后序遍历都由dfs产生</span>
<span class="hljs-comment">先序遍历即为dfs序节点入栈顺序</span>
<span class="hljs-comment">后序遍历即为dfs序节点出栈顺序</span>
<span class="hljs-comment">*/</span></code></pre></div>
<h3 id="1-4-树的深度"><a href="#1-4-树的深度" class="headerlink" title="[1.4]树的深度"></a>[1.4]树的深度</h3><script type="math/tex; mode=display">
d[son] = d[father] + 1</script><h3 id="1-5-树的重心"><a href="#1-5-树的重心" class="headerlink" title="[1.5]树的重心"></a>[1.5]树的重心</h3><script type="math/tex; mode=display">
size[father] = 1+\sum size[son]</script><script type="math/tex; mode=display">
size[leaf] = 1</script><p>当删除树中的某一个<strong>节点</strong>后会产生若干<strong>不连续</strong>的<strong>子树</strong>，定义函数<code>max_part(x)</code>为删除节点$x$后产生的最大<strong>子树</strong>的$size$</p>
<p>存在节点$x=p$使<code>max_part(p)</code>最小，则$p$为该树<strong>重心</strong>。</p>
<div class="hljs"><pre><code class="hljs cpp"><span class="hljs-comment">//寻找重心</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">dfs</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x)</span></span>&#123;
    flag[x] = <span class="hljs-literal">true</span> , size[x] = <span class="hljs-number">1</span> , max_part = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[i])&#123;
        y = ver[i];
        <span class="hljs-keyword">if</span>(flag[y]) <span class="hljs-keyword">continue</span>;
        dfs(y);
        size[x] += size[y];
        max_part = max_part &gt; size[y] ? max_part : size[y];
    &#125;
    max_part = max_part &gt; (n - size[x]) ? max_part : (n - size[x]);<span class="hljs-comment">//可能以“父”为“子”情况更优</span>
    <span class="hljs-keyword">if</span>(max_part &gt; ans) ans = max_part , pos = x;
    <span class="hljs-keyword">return</span>;<span class="hljs-comment">//return的高亮非常好看，所以要多打(雾)</span>
&#125;</code></pre></div>
<h3 id="1-6-树与图的广度优先遍历以及拓扑排序"><a href="#1-6-树与图的广度优先遍历以及拓扑排序" class="headerlink" title="[1.6]树与图的广度优先遍历以及拓扑排序"></a>[1.6]树与图的广度优先遍历以及拓扑排序</h3><div class="hljs"><pre><code class="hljs cpp"><span class="hljs-comment">//广搜遍历储存在邻接表里的图，顺便计算深度</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">bfs</span><span class="hljs-params">()</span></span>&#123;
    初始化;
    <span class="hljs-built_in">queue</span>&lt;<span class="hljs-keyword">int</span>&gt; q;
    q.push(<span class="hljs-number">1</span>);    d[<span class="hljs-number">1</span>] = <span class="hljs-number">1</span>;
    <span class="hljs-keyword">while</span>(q.size() &gt; <span class="hljs-number">0</span>)&#123;
        <span class="hljs-keyword">int</span> x = q.front();    q.pop();
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[i])&#123;
            <span class="hljs-keyword">int</span> y = ver[i];
            <span class="hljs-keyword">if</span>(d[y]) <span class="hljs-keyword">continue</span>;<span class="hljs-comment">//d[]兼具flag[]职能</span>
            d[i] = d[x] + <span class="hljs-number">1</span>;
            q.push(y);
        &#125;
    &#125;
&#125;
<span class="hljs-comment">/*</span>
<span class="hljs-comment">广搜图具有以下性质：</span>
<span class="hljs-comment">只有处理完每一层的节点后才会去处理下一层的节点</span>
<span class="hljs-comment">队列中至多存在连层节点</span>
<span class="hljs-comment">*/</span></code></pre></div>
<hr>
<p><strong>拓扑排序/topsort</strong></p>
<p><strong>定义</strong>：求解<strong>拓扑序</strong>的过程。拓扑序满足：</p>
<ul>
<li>给定有向<strong>无环</strong>图，对于所有的边$(x,y)$，有所有$x$必然出现在$y$前。</li>
</ul>
<div class="hljs"><pre><code class="hljs cpp"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">topsort</span><span class="hljs-params">()</span></span>&#123;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">1</span>;i &lt;= n;i++) <span class="hljs-keyword">if</span>(deg[i] == <span class="hljs-number">0</span>) q.push(i);
    <span class="hljs-keyword">while</span>(q.size())&#123;
        <span class="hljs-keyword">int</span> x = q.front();    q.pop();
        top[++cnto] = x;
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = head[x];i;i = next[i])&#123;
            <span class="hljs-keyword">int</span> y = ver[i];
            <span class="hljs-keyword">if</span>(--deg[y] == <span class="hljs-number">0</span>) q.push(y);
        &#125;
    &#125;
&#125;
<span class="hljs-comment">//如果不保证无环，那么最终拓扑序长度会小于节点数</span></code></pre></div>
<p><strong>相关题目</strong>：<del><a target="_blank" rel="noopener" href="https://www.luogu.org/problem/P1038">P1038 神经网络</a></del></p>
<h2 id="2-x-深搜"><a href="#2-x-深搜" class="headerlink" title="[2.x]深搜"></a>[2.x]深搜</h2><ul>
<li>搜索树</li>
<li>剪枝</li>
</ul>
<h3 id="2-1-相关题目"><a href="#2-1-相关题目" class="headerlink" title="[2.1]相关题目"></a>[2.1]相关题目</h3><p><del><a target="_blank" rel="noopener" href="https://www.luogu.org/problem/P1706">P1706 全排列问题</a></del></p>
<p><del><a target="_blank" rel="noopener" href="https://www.luogu.org/problem/P1219">八皇后</a></del></p>
<h2 id="3-x-剪枝"><a href="#3-x-剪枝" class="headerlink" title="[3.x]剪枝"></a>[3.x]剪枝</h2><ul>
<li>优化搜索顺序</li>
<li>排除等效冗余</li>
<li>可行性剪枝</li>
<li>最优性剪枝</li>
<li>记忆化</li>
</ul>
<h2 id="4-x-广搜"><a href="#4-x-广搜" class="headerlink" title="[4.x]广搜"></a>[4.x]广搜</h2><h2 id="5-x-广搜变形"><a href="#5-x-广搜变形" class="headerlink" title="[5.x]广搜变形"></a>[5.x]广搜变形</h2><h3 id="5-1-双端队列BFS"><a href="#5-1-双端队列BFS" class="headerlink" title="[5.1]双端队列BFS"></a>[5.1]双端队列BFS</h3><p>对于边权为0/1的图，我们可以通过在广搜过程中将边权为1的正常入队，边权为0的从<strong>队首</strong>入队，即在下一次bfs中再对队首元素进行bfs，即等效于给它<strong>加课</strong>，使保证队列中<strong>至多有两层</strong>的性质。</p>
<h3 id="5-2-优先队列BFS"><a href="#5-2-优先队列BFS" class="headerlink" title="[5.2]优先队列BFS"></a>[5.2]优先队列BFS</h3><p>优先队列适用于非负权值随机的图，用优先队列维护处理队列，排序依据为当前节点最小权值和方案。(蓝书P121)</p>
<h3 id="5-3-双向bfs"><a href="#5-3-双向bfs" class="headerlink" title="[5.3]双向bfs"></a>[5.3]双向bfs</h3><p>两个bfs一起跑</p>
<link rel="stylesheet" href="/blog/css/spoiler.css" type="text/css"><script src="/blog/js/spoiler.js" type="text/javascript" async></script>
            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/blog/categories/%E7%AE%97%E6%B3%95/">算法</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E7%AE%97%E6%B3%95/">算法</a>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E4%BF%A1%E5%A5%A5/">信奥</a>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E4%B8%93%E9%A2%98/">专题</a>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E6%90%9C%E7%B4%A2/">搜索</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">未经允许禁止用于商业用途，转载请标注出处和作者！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2019/11/09/self-examination/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">other-做题反思</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2019/11/07/algdp/">
                        <span class="hidden-mobile">algorithm-dp动态规划专题</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments">
                
                <!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC80ODI4NS8yNDc3OQ==">
  <script type="text/javascript">
     (function(d, s) {
         var j, e = d.getElementsByTagName(s)[0];
  
         if (typeof LivereTower === 'function') { return; }
  
         j = d.createElement(s);
         j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
         j.async = true;
  
         e.parentNode.insertBefore(j, e);
     })(document, 'script');
  </script>
  <noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
  </div>
  <!-- City版安装代码已完成 -->
              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->

  <div class="col-lg-7 mx-auto nopadding-md">
    <div class="container custom post-content mx-auto">
      <p><center><b>(っ*´Д`)っ㊖ <font color="darkblue">  疯 狂 暗 示  </font>(っ*´Д`)っ㊖</b></center></p><center><img src="https://pic.downk.cc/item/5f3bd3b414195aa59408fb13.png" srcset="/blog/img/loading.gif" width="50%" height="50%"/></center>
    </div>
  </div>


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  
    <!-- APlayer 音乐播放器 -->
    <div id="aplayer"></div>
    <script defer src="https://cdn.staticfile.org/aplayer/1.10.1/APlayer.min.js" ></script>
<link  rel="stylesheet" href="https://cdn.staticfile.org/aplayer/1.10.1/APlayer.min.css" />
<script type="text/javascript">
  var oldLoadAp = window.onload;
  window.onload = function () {
    oldLoadAp && oldLoadAp();

    new APlayer({
      container: document.getElementById('aplayer'),
      fixed: true,
      autoplay: 'false' === 'true',
      loop: 'all',
      order: 'random',
      theme: '#708090',
      preload: 'none',
      audio: [{"name":"SLEEPWALK","artist":"冰镇豆沙君","url":"http://music.163.com/song/media/outer/url?id=1417007045.mp3","cover":"/img/cover.jpg"},{"name":"雨き声残响","artist":"冰镇豆沙君","url":"http://music.163.com/song/media/outer/url?id=1318309030.mp3","cover":"/img/cover.jpg"},{"name":"春を告げる","artist":"茶玖","url":"http://music.163.com/song/media/outer/url?id=1460240705.mp3","cover":"/img/cover.jpg"},{"name":"ベクターフィッシュ","artist":"茶玖","url":"http://music.163.com/song/media/outer/url?id=1445572300.mp3","cover":"/img/cover.jpg"},{"name":"红莲华","artist":"噢耶","url":"http://music.163.com/song/media/outer/url?id=1397590357.mp3","cover":"/img/cover.jpg"},{"name":"横竖撇点折","artist":"噢耶","url":"http://music.163.com/song/media/outer/url?id=1421414775.mp3","cover":"/img/cover.jpg"},{"name":"たぶん","artist":"真央","url":"http://music.163.com/song/media/outer/url?id=1464762744.mp3","cover":"/img/cover.jpg"},{"name":"夜に駆ける","artist":"真央","url":"http://music.163.com/song/media/outer/url?id=1461930738.mp3","cover":"/img/cover.jpg"},{"name":"Alice","artist":"yakuri","url":"http://music.163.com/song/media/outer/url?id=1431092750.mp3","cover":"/img/cover.jpg"},{"name":"起风了","artist":"yakuri","url":"http://music.163.com/song/media/outer/url?id=1367440424.mp3","cover":"/img/cover.jpg"}]
    });
  }
</script>

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/debouncer.js" ></script>
<script  src="/blog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/blog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/blog/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 6,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "algorithm-搜索专题&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 50,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>





  <script  src="/blog/js/local-search.js" ></script>
  <script>
    var path = "/blog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>





  

  
    <!-- MathJax -->
    <script>
      MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']]
        },
        options: {
          renderActions: {
            findScript: [10, doc => {
              document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
                const display = !!node.type.match(/; *mode=display/);
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                const text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = { node: text, delim: '', n: 0 };
                math.end = { node: text, delim: '', n: 0 };
                doc.math.push(math);
              });
            }, '', false],
            insertedScript: [200, () => {
              document.querySelectorAll('mjx-container').forEach(node => {
                let target = node.parentNode;
                if (target.nodeName.toLowerCase() === 'li') {
                  target.parentNode.classList.add('has-jax');
                }
              });
            }, '', false]
          }
        }
      };
    </script>

    <script async src="https://cdn.staticfile.org/mathjax/3.0.5/es5/tex-svg.js" ></script>

  



  
  
    <script type="text/javascript">
      //定义获取词语下标
      var a_idx = 0;
      jQuery(document).ready(function ($) {
        //点击body时触发事件
        $("body").click(function (e) {
          //需要显示的词语
          var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
          //设置词语给span标签
          var $i = $("<span/>").text(a[a_idx]);
          //下标等于原来下标+1  余 词语总数
          a_idx = (a_idx + 1) % a.length;
          //获取鼠标指针的位置，分别相对于文档的左和右边缘。
          //获取x和y的指针坐标
          var x = e.pageX, y = e.pageY;
          //在鼠标的指针的位置给$i定义的span标签添加css样式
          $i.css({
            "z-index": 999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": rand_color()
          });
          // 随机颜色
          function rand_color() {
            return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
          }
          //在body添加这个标签
          $("body").append($i);
          //animate() 方法执行 CSS 属性集的自定义动画。
          //该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的，这样就可以创建动画效果。
          //详情请看http://www.w3school.com.cn/jquery/effect_animate.asp
          $i.animate({
            //将原来的位置向上移动180
            "top": y - 180,
            "opacity": 0
            //1500动画的速度
          }, 1500, function () {
            //时间到了自动删除
            $i.remove();
          });
        });
      })
      ;
    </script>
  














<script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/blog/live2dw/assets/assets/hijiki.model.json"},"display":{"superSample":1,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true,"scale":1},"react":{"opacityDefault":0.7,"opacityOnHover":0.2},"log":false});</script></body>
</html>
